/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.ruby_string.delayed;

import picounit.util.Equal;
import picounit.verify.constraint.EqualUtil;
import moved.org.objectweb.asm.MethodVisitor;

public class VarInstruction extends AbstractMethodInstruction implements Equal<VarInstruction>{
	private final int opcode;
	private final int var;

	public VarInstruction(int opcode, int var) {
		this.opcode = opcode;
		this.var = var;
	}
	
	public boolean matches(int opcode, int var) {
		return this.opcode == opcode && this.var == var;
	}

	///////////////////////////////////////////////////////////////////////////////////////////////
	// Equal methods
	///////////////////////////////////////////////////////////////////////////////////////////////
	
	public boolean equalTo(VarInstruction other) {
		return other.matches(opcode, var);
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	// MethodInstruction Methods
	///////////////////////////////////////////////////////////////////////////////////////////////
	
	public void accept(MethodVisitor methodVisitor) {
		methodVisitor.visitVarInsn(opcode, var);
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	// Object Methods
	///////////////////////////////////////////////////////////////////////////////////////////////

	@Override
	public boolean equals(Object object) {
		return EqualUtil.isEqual(this, object);
	}
}
